package com.hog.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * 监听程序启动完成
 *
 * @author 糖先森
 * @date 2018年03月21日
 * @since JDK 1.8
 */
@Component
public class ApplicationStartupListener implements ApplicationListener<ContextRefreshedEvent> {
    private final static Logger LOG = LoggerFactory.getLogger(ApplicationStartupListener.class);
    @Value("${server.port}")
    private int serverPort = 0;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        LOG.info("程序启动完成, 访问: http://localhost:{}/", serverPort);
    }
}